import Vue from 'vue'
import Vuex from 'vuex'
import user from './modules/user'
import home from './modules/home'
import persistedstate from 'vuex-persistedstate'
// 持久化：1：值修改了存储到浏览器2：初始值读取浏览器存储
// vuex持久化插件  vuex-persistedstate
// 1:下载
// 2：导入 import persistedstate from 'vuex-persistedstate'
// 3:配制  plugins:[persistedstate({paths:['需要持久化的数据(user/user.username))']})]
Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    rootName: '我是根模块'
  },
  getters: {
    getName (state) {
      return 'rootGetters:' + state.rootName
    }
  },
  mutations: {},
  actions: {},
  modules: {
    user,
    home
  },
  plugins: [persistedstate({ paths: ['user.username'] })]
})
